package com.ztw.yygh.cmn.controller;

import com.baomidou.mybatisplus.extension.api.R;
import com.ztw.yygh.cmn.service.HospitalService;
import com.ztw.yygh.common.result.Result;
import com.ztw.yygh.model.hosp.Hospital;
import com.ztw.yygh.vo.hosp.HospitalQueryVo;
import com.ztw.yygh.vo.hosp.HospitalSetQueryVo;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/admin/hosp/hospital")
public class HospitalController {
    @Resource
    private HospitalService hospitalService;

    //医院详情
    @GetMapping("showHospDetail/{id}")
    public Result showHospDetail(@PathVariable String id) {
        Map<String,Object> map = hospitalService.getHospById(id);
        return Result.ok(map);
    }
    //医院列表
    @GetMapping("/list/{page}/{limit}")
    public Result listHosp(@PathVariable Integer page,
                           @PathVariable Integer limit,
                           HospitalQueryVo hospitalQueryVo) {
        Page<Hospital> pageModel = hospitalService.selectHospPage(page, limit, hospitalQueryVo);
        return Result.ok(pageModel);
    }

    //更改状态
    @GetMapping("updateHospStatus/{id}/{status}")
    public Result updateHospStatus(@PathVariable String id, @PathVariable Integer status) {
        hospitalService.updateStatus(id,status);
        return Result.ok();
    }
}
